package com.lang.timetask;

import java.util.TimerTask;

import com.lang.beans.Parcel;
import com.lang.beans.User;
import com.lang.service.ParcelService;
import com.lang.service.UserService;

public class AddParcelsTask extends TimerTask {

	private ParcelService parcelservice;
	private UserService userservice;

	public ParcelService getParcelservice() {
		return parcelservice;
	}

	public void setParcelservice(ParcelService parcelservice) {
		this.parcelservice = parcelservice;
	}

	public UserService getUserservice() {
		return userservice;
	}

	public void setUserservice(UserService userservice) {
		this.userservice = userservice;
	}

	// 进行公平分配任务
	@Override
	public void run(){
		// TODO Auto-generated method stub
		System.out.println("20秒执行一次 包裹添加");
		User user=userservice.getUserInfo("1000");
        Parcel p=new Parcel();
        p.setSendName("李小萌");
        p.setSendTel("15649848411");
        p.setSendAddr("广东从化");
        p.setRecName("王五");
        p.setRecTel("12548798777");
        p.setRecAddr("北京中关村");
        p.setSize(1);
        p.setType(0);
        p.setWeight(1f);
        p.setStatus(0);
        p.setTransType(0);
        p.setUser(user);
        p.setPayType(1);
        p.setComment("test!!");      
        parcelservice.addPackage(p);       
		System.out.println("包裹添加完毕!!");
	}
}
